(symbols "listAsCollection" 'pico)

(local
  *BooleanType
  *ObjectClass
  *ListClass)

(setq
  *BooleanType (public "java.lang.Boolean" "TYPE")
  *ObjectClass (javaClass "java.lang.Object")
  *ListClass (javaClass "java.util.List") )

(when (>= (javaVersion T) (1 7) )
  (de pico~listAsCollection (List)
    (if List
      (let (Length (length List)
            ArrayList (java "java.util.ArrayList" T Length)
            Add (thread ArrayList
                  (constantMethodHandle *ListClass)
                  (composeMethodHandle
                    (methodHandle "Virtual" *ListClass
                      "add" *BooleanType *ObjectClass) ) ) )
        (for @Item List
          (thread "java.util.concurrent.Callable"
            (functionalInterface (curry (@Item) @ @Item) )
            (functionalInterfaceAsMethodHandle *ObjectClass)
            (composeMethodHandle Add)
            pico~invokeMethodHandle) )
        ArrayList)
      (java "java.util.ArrayList" T) ) ) )